package com.hjm.project.merchantInfo.change.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.hjm.framework.aspectj.lang.annotation.Log;
import com.hjm.framework.aspectj.lang.enums.BusinessType;
import com.hjm.project.merchantInfo.change.domain.InformationChange;
import com.hjm.project.merchantInfo.change.service.IInformationChangeService;
import com.hjm.framework.web.controller.BaseController;
import com.hjm.framework.web.domain.AjaxResult;
import com.hjm.common.utils.poi.ExcelUtil;
import com.hjm.framework.web.page.TableDataInfo;

/**
 * 信息变更记录Controller
 * 
 * @author LOVE
 * @date 2020-11-26
 */
@Controller
@RequestMapping("/merchantInfo/change")
public class InformationChangeController extends BaseController
{
    private String prefix = "merchantInfo/change";

    @Autowired
    private IInformationChangeService informationChangeService;

    @RequiresPermissions("merchantInfo:change:view")
    @GetMapping()
    public String change()
    {
        return prefix + "/change";
    }

    /**
     * 查询信息变更记录列表
     */
    @RequiresPermissions("merchantInfo:change:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(InformationChange informationChange)
    {
        startPage();
        List<InformationChange> list = informationChangeService.selectInformationChangeList(informationChange);
        return getDataTable(list);
    }

    /**
     * 导出信息变更记录列表
     */
    @RequiresPermissions("merchantInfo:change:export")
    @Log(title = "信息变更记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(InformationChange informationChange)
    {
        List<InformationChange> list = informationChangeService.selectInformationChangeList(informationChange);
        ExcelUtil<InformationChange> util = new ExcelUtil<InformationChange>(InformationChange.class);
        return util.exportExcel(list, "change");
    }

    /**
     * 新增信息变更记录
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存信息变更记录
     */
    @RequiresPermissions("merchantInfo:change:add")
    @Log(title = "信息变更记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(InformationChange informationChange)
    {
        return toAjax(informationChangeService.insertInformationChange(informationChange));
    }

    /**
     * 修改信息变更记录
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        InformationChange informationChange = informationChangeService.selectInformationChangeById(id);
        mmap.put("informationChange", informationChange);
        return prefix + "/edit";
    }

    /**
     * 修改保存信息变更记录
     */
    @RequiresPermissions("merchantInfo:change:edit")
    @Log(title = "信息变更记录", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(InformationChange informationChange)
    {
        return toAjax(informationChangeService.updateInformationChange(informationChange));
    }

    /**
     * 删除信息变更记录
     */
    @RequiresPermissions("merchantInfo:change:remove")
    @Log(title = "信息变更记录", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(informationChangeService.deleteInformationChangeByIds(ids));
    }
}
